﻿Option Strict Off
Option Explicit On

Imports System.Runtime.InteropServices
Imports ADODB

<ProgId("ServicioSRM_NET.ServicioSRM")> _
Public Class ServicioSRM
    Private m_CodigoServicio As Integer
    Private m_Nodo As String
    Private m_Aplicacion As String
    Private m_Tipo As String
    Private m_Contexto As String

    Private m_SleepNro As Integer
    Private m_SleepTime As Integer

    Private m_Retorno As Integer
    Private m_RetornoApp As Short
    Private m_RetornoSrm As Integer
    Private m_StatusSrm As Short

    Public Property CodigoServicio() As Integer
        Get
            CodigoServicio = m_CodigoServicio
        End Get
        Set(ByVal Value As Integer)
            m_CodigoServicio = Value
        End Set
    End Property

    Public Property Nodo() As String
        Get
            Nodo = m_Nodo
        End Get
        Set(ByVal Value As String)
            m_Nodo = Value
        End Set
    End Property

    Public Property Aplicacion() As String
        Get
            Aplicacion = m_Aplicacion
        End Get
        Set(ByVal Value As String)
            m_Aplicacion = Value
        End Set
    End Property

    Public Property Tipo() As String
        Get
            Tipo = m_Tipo
        End Get
        Set(ByVal Value As String)
            m_Tipo = Value
        End Set
    End Property

    Public Property Contexto() As String
        Get
            Contexto = m_Contexto
        End Get
        Set(ByVal Value As String)
            m_Contexto = Value
        End Set
    End Property

    Public Property SleepNro() As Integer
        Get
            SleepNro = m_SleepNro
        End Get
        Set(ByVal Value As Integer)
            m_SleepNro = Value
        End Set
    End Property

    Public Property SleepTime() As Integer
        Get
            SleepTime = m_SleepTime
        End Get
        Set(ByVal Value As Integer)
            m_SleepTime = Value
        End Set
    End Property

    Public Property Retorno() As Integer
        Get
            Retorno = m_Retorno
        End Get
        Set(ByVal Value As Integer)
            m_Retorno = Value
        End Set
    End Property

    Public Property RetornoApp() As Integer
        Get
            RetornoApp = m_RetornoApp
        End Get
        Set(ByVal Value As Integer)
            m_RetornoApp = Value
        End Set
    End Property

    Public Property RetornoSrm() As Integer
        Get
            RetornoSrm = m_RetornoSrm
        End Get
        Set(ByVal Value As Integer)
            m_RetornoSrm = Value
        End Set
    End Property

    Public Property StatusSrm() As Integer
        Get
            StatusSrm = m_StatusSrm
        End Get
        Set(ByVal Value As Integer)
            m_StatusSrm = Value
        End Set
    End Property

    Public Function Clone() As ServicioSRM

        Dim newSRMInfo As ServicioSRM

        newSRMInfo = New ServicioSRM

        With newSRMInfo
            .CodigoServicio = m_CodigoServicio
            .Nodo = m_Nodo
            .Aplicacion = m_Aplicacion
            .Tipo = m_Tipo
            .Contexto = m_Contexto
            .SleepNro = m_SleepNro
            .SleepTime = m_SleepTime
        End With

        Clone = newSRMInfo
    End Function

    ''Public Function Save(ByVal CodigoServicio As Integer) 'As RetornoExec


    'Dim oRs As Recordset
    'Dim Retorno As RetornoExec
    'Dim SQL As String

    'On Error GoTo ErrSave

    'Retorno = New RetornoExec

    'OpenConnection()

    'SQL = "sp_GuardarServicioSRM "

    'SQL = SQL & CodigoServicio & ","
    'SQL = SQL & "'" & m_Nodo & "',"
    'SQL = SQL & "'" & m_Aplicacion & "',"
    'SQL = SQL & "'" & VB6.Format(Val(m_Tipo), "00") & "',"
    'SQL = SQL & "'" & VB6.Format(Val(m_Contexto), "00") & "',"
    'SQL = SQL & m_SleepNro & ","
    'SQL = SQL & m_SleepTime

    'oRs = conn.Execute(SQL)
    'If Not oRs.EOF Then
    'Guardar informacion procedimiento almacenado
    '        Retorno.CodigoExt = oRs.Fields("Retorno").Value
    '        Retorno.DescripcionExt = oRs.Fields("Glosa").Value

    ''Verificar si hubo problemas durante la ejecucion
    '        If Retorno.CodigoExt <> ResultOK Then
    '            Retorno.Codigo = ERROR_SAVE_DATASRM
    '            Retorno.Descripcion = "Error al guardar información SRM"
    '        End If
    '    Else
    ''Guardar retornos de error
    '        Retorno.Codigo = ERROR_SAVE_INVOKE
    '        Retorno.Descripcion = "Error durante la ejecución del componente"

    '            Retorno.CodigoExt = Retorno.Codigo
    '            Retorno.DescripcionExt = Retorno.Descripcion
    '        End If
    '        oRs.Close()

    'ExitSave:
    '        On Error Resume Next

    '    'UPGRADE_NOTE: El objeto oRs no se puede destruir hasta que no se realice la recolección de los elementos no utilizados. Haga clic aquí para obtener más información: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6E35BFF6-CD74-4B09-9689-3E1A43DF8969"'
    '        oRs = Nothing
    '        CloseConnection()

    '        Save = Retorno

    '        Exit Function

    'ErrSave:

    '        Retorno.Codigo = ERROR_SAVE_UNDEFINED
    '        Retorno.Descripcion = "Error en tiempo de ejecución"

    '        Retorno.CodigoExt = Err.Number
    '        Retorno.DescripcionExt = Err.Description

    '        GoTo ExitSave
    '    End Function


    '    Public Function Load(ByVal CodigoServicio As Integer) As Integer
    '        Dim SQL As String
    '        Dim Rs As Recordset

    '        On Error GoTo ErrLoad

    '        Load = ResultOK

    '        OpenConnection()

    '        m_CodigoServicio = CodigoServicio

    '        SQL = "SELECT * FROM ServicioSRM WHERE CodServicio =" & CodigoServicio

    '        Rs = conn.Execute(SQL)
    '        If Rs.EOF Then
    '            Load = ERROR_LOADINFOSRM_NOTFOUND
    '            GoTo ExitLoad
    '        End If

    '        m_Nodo = Rs.Fields("Nodo").Value
    '        m_Aplicacion = Rs.Fields("Apli").Value
    '        m_Tipo = Rs.Fields("Tipo").Value
    '        m_Contexto = Rs.Fields("Contexto").Value

    '        'UPGRADE_WARNING: Se detectó el uso de Null/IsNull(). Haga clic aquí para obtener más información: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="2EED02CB-5C0E-4DC1-AE94-4FAA3A30F51A"'
    '        If Not IsDBNull(Rs.Fields("NroLlamEsp").Value) Then
    '            m_SleepNro = Rs.Fields("NroLlamEsp").Value
    '        End If
    '        'UPGRADE_WARNING: Se detectó el uso de Null/IsNull(). Haga clic aquí para obtener más información: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="2EED02CB-5C0E-4DC1-AE94-4FAA3A30F51A"'
    '        If Not IsDBNull(Rs.Fields("TiempoEsp").Value) Then
    '            m_SleepTime = Rs.Fields("TiempoEsp").Value
    '        End If

    'ExitLoad:
    '        On Error Resume Next

    '        '' '' '' ''If Not Rs Is Nothing Then
    '        '' '' '' ''    If Rs.State = ObjectStateEnum.adStateOpen Then
    '        '' '' '' ''        Rs.Close()
    '        '' '' '' ''    End If
    '        '' '' '' ''    'UPGRADE_NOTE: El objeto Rs no se puede destruir hasta que no se realice la recolección de los elementos no utilizados. Haga clic aquí para obtener más información: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6E35BFF6-CD74-4B09-9689-3E1A43DF8969"'
    '        '' '' '' ''    Rs = Nothing
    '        '' '' '' ''End If
    '        '' '' '' ''CloseConnection()

    '        Exit Function

    'ErrLoad:

    '        Load = ERROR_LOADINFOSRM_UNDEFINED

    '        GoTo ExitLoad

    '    End Function
End Class